package com.godfrey.springcloud.controller;

import com.godfrey.springcloud.pojo.Dept;
import com.godfrey.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author godfrey
 * @since 2020-11-18
 */
@RestController
public class DeptConsumerController {

    private DeptClientService service;

    @Autowired
    public DeptConsumerController(DeptClientService service) {
        this.service = service;
    }

    @PostMapping("/consumer/dept/add")
    public boolean addDept(Dept dept) {
        return service.addDept(dept);
    }

    @GetMapping("/consumer/dept/get/{id}")
    public Dept queryById(@PathVariable("id") Long id) {
        return service.queryById(id);
    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> queryAll() {
        return service.queryAll();
    }
}
